# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan De Groot <jgc@archlinux.org>

pkgname=gnome-keyring
pkgver=42.1
pkgrel=2
epoch=1
pkgdesc="Stores passwords and encryption keys"
url="https://wiki.gnome.org/Projects/GnomeKeyring"
arch=(x86_64)
license=(GPL LGPL)
depends=(gcr gcr-4 libcap-ng pam openssh)
makedepends=(git docbook-xsl python p11-kit)
provides=(org.freedesktop.secrets)
groups=(gnome)
install=gnome-keyring.install
_commit=9d562e1e359e3ce01b61f0f52c75d38b96dece7b  # tags/42.1^0
source=("git+https://gitlab.gnome.org/GNOME/gnome-keyring.git#commit=$_commit"
        0001-build-Use-p11_module_configs-as-default-pkcs11-confi.patch
        0002-daemon-Add-Cinnamon-to-autostart-files.patch)
sha256sums=('SKIP'
            '6985e3f7c60aa8dad794b1a9466f69737f3e9b5b7176e3888252c8c56647736a'
            '91538221b304ef951a7d6d7441f8609a2787f725e55d60788b51e81f38c9012f')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd $pkgname

  # Fix pkcs11 config dir
  git apply -3 ../0001-build-Use-p11_module_configs-as-default-pkcs11-confi.patch

  # Autolaunch in Cinnamon
  git apply -3 ../0002-daemon-Add-Cinnamon-to-autostart-files.patch

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgname
  ./configure --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir=/usr/lib \
    --with-pam-dir=/usr/lib/security \
    --disable-static \
    --disable-schemas-compile
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd $pkgname
  # Secure memory tests fail
  dbus-run-session make -k check || :
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
}
